{include file="inc/header.html"} 
<div id="bdw" class="bdw">
	<div id="bd" class="cf">
		{if $deal.buy_status eq 2}
		{include file="inc/sold_out_tip.html"} 
		{/if}
		{if $coupon_data}
		{include file="inc/new_coupon_tip.html"} 
		{/if}
		<div id="deal-default">
			<div id="content">
				{include file="inc/share.html"} 
				<div id="deal-intro" class="cf">
					<h1>
						{$deal.name}				
					</h1>
					<div class="main">
						<div class="deal-buy">
							<div class="deal-price-tag"></div>
							<p class="deal-price" id="deal-price">
								<strong>{$deal.current_price_format}</strong>
								<!--begin button status-->
								{if $deal.time_status eq 0} {*/未开始/*}
								<span>		
									<a href="javascript:void(0);">					
										<img src="{$TMPL}/images/bg-deal-wait-text.gif">	
									</a>								
								</span>
								{/if}
								{if $deal.time_status eq 1}{*/已开始/*}
									{if $deal.buy_status eq 2} {*/卖光/*}
									<span>
										<a href="javascript:void(0);">
											<img src="{$TMPL}/images/bg-deal-soldout-text.gif">
										</a>
									</span>
									{else}
									<span>
										<a href="javascript:void(0);" onclick="add_cart({$deal.id})">
											<img src="{$TMPL}/images/button-deal-buy.gif">
										</a>
									</span>
									{/if}
								{/if}
								{if $deal.time_status eq 2} {*/已过期/*}
									{if $deal.buy_status eq 2} {*/卖光/*}
									<span>
											<a href="javascript:void(0);">
												<img src="{$TMPL}/images/bg-deal-soldout-text.gif">
											</a>
										</span>
									{else}
									<span>		
										<a href="javascript:void(0);">					
											<img src="{$TMPL}/images/bg-deal-expired-text.gif">	
										</a>								
									</span>
									{/if}
								{/if}
								<!--end button status-->		
							</p>
						</div>
						<table class="deal-discount">
							<tbody>
								<tr>
									<th>{$LANG.ORIGIN_PRICE}</th>
									<th>{$LANG.DISCOUNT}</th>
									<th>{$LANG.SAVE_PRICE}</th>
								</tr>
								<tr>
									<td>{$deal.origin_price_format}</td>
									<td>{$deal.discount}{$LANG.DISCOUNT_OFF}</td>
									<td>{$deal.save_price_format}</td>
								</tr>

							</tbody>
						</table>
						{if ($deal.begin_time ne 0 and $deal.time_status eq 0) or ($deal.end_time ne 0 and $deal.time_status eq 1)} {* 时间 *}
						<div id="deal-timeleft-box">
							<div id="deal-timeleft" class="deal-box deal-timeleft deal-on">
								<h3>{$LANG.TIME_LEFT}</h3>
								<div class="limitdate">
									<ul id="counter"></ul>
								</div>
							</div>						
						</div>
						{/if}

						<div id=deal-status class="deal-box deal-status deal-status-open">
							
						{if $deal.time_status eq 0}{*/未开始/*}
							{$LANG.DEAL_NOT_BEGIN}
							<br />
							{function name='sprintf' format=$LANG.DEAL_BEGIN_FORMAT value=$deal.begin_time_format}
						{/if}
						{if $deal.time_status eq 1} {*/进行中/*}
							{if $deal.buy_status eq 0} {*/未成功/*}
								<p class=deal-buy-tip-top>{$deal.deal_success_num}</p>
								<p class="deal-buy-tip-notice">{$LANG.DEAL_LIMIT_TIP}</p>
								<div class="progress-pointer" style="padding-left:<?php echo $this->_var['deal']['current_bought'] / $this->_var['deal']['min_bought'] * 194 -5; ?>px;"><span></span></div>
								<div class="progress-bar">
							
									<div class="progress-left" style="width:<?php echo $this->_var['deal']['current_bought'] / $this->_var['deal']['min_bought'] * 194; ?>px;"></div>
									<div class="progress-right "></div>
								</div>
								<div class="cf">
									<div class="min">0</div>
									<div class="max">{$deal.min_bought}</div>
								</div>
								<p class="deal-buy-tip-btm">{$deal.success_less}</p>
							{/if}
							{if $deal.buy_status eq 1} {*/成功/*}
								<p class=deal-buy-tip-top>{$deal.deal_success_num}</p>
								<p class="deal-buy-tip-notice">
									<?PHP
									$c_deal = $this->_var['deal'];
									if($c_deal['max_bought'] != 0 && $c_deal['max_bought'] - $c_deal['buy_count'] <= 10)
									{
										echo sprintf($GLOBALS['lang']['REMAIN_TIP'],$c_deal['max_bought'] - $c_deal['buy_count']);
									}
									?>
									{$LANG.DEAL_LIMIT_TIP}</p>
								<p class=deal-buy-on>{$LANG.DEAL_SUCCESS_CONTINUE_BUY}</p>
								<p class=deal-buy-tip-btm>{$deal.success_time_tip}</p>
							{/if}
							{if $deal.buy_status eq 2} {*/卖光/*}
							<p class=deal-buy-tip-top>{$deal.deal_success_num}</p>
							<img src="{$TMPL}/images/bg-sold-out.gif">
							{/if}							
						{/if}
						{if $deal.time_status eq 2} {*/过期/*}
							{if $deal.buy_status eq 0} {*/失败/*}
							<img src="{$TMPL}/images/bg-deal-expired-fail.gif">
							{/if}
							{if $deal.buy_status eq 1} {*/成功/*}
							<p class=deal-buy-tip-top>{$deal.deal_success_num}</p>
							<img src="{$TMPL}/images/bg-deal-expired-success.gif">
							{/if}
							{if $deal.buy_status eq 2} {*/卖光/*}
							<p class=deal-buy-tip-top>{$deal.deal_success_num}</p>
							<img src="{$TMPL}/images/bg-sold-out.gif">
							{/if}
						{/if}
						
						</div>
					</div>
					<div class=side>
						<div id="goods_imgs" class="deal-buy-cover-img">
							<div class="mid">
								<ul>
								{foreach from=$deal.image_list key=key item=image}
								<li {if $key eq 0}class="first"{/if}>
								<img src="{$image.img}">
								</li>
								{/foreach}								
								</ul>
								<div id="img_list">
									{if count($deal.image_list) gt 1}
									{foreach from=$deal.image_list key=key item=image}
									<a {if $key eq 0}class="active"{/if} ref="<?php echo $this->_var['key']+1;?>"><?php echo $this->_var['key']+1;?></a>
									{/foreach}	
									{/if}							
								</div>
							</div>
						</div>					
						<div class=digest>
							{$deal.brief}
						</div>
					</div>
				</div>

				<div id=deal-stuff class=cf>
					
					<div class="box box-split">
						<div class=box-top></div>
						<div class="box-content cf">
							<div class=main>
								<H2>{$LANG.DEAL_DETAIL}</H2>
								{$deal.description}
								<div class="blank"></div>
								<H2>{$LANG.SUPPLIER_DETAIL}</H2>
								{$deal.supplier_info.content}
							</div>
							<div class=side>
								<div id=side-business>
									<H2>{$deal.supplier_info.name}  </H2>
									<?PHP if(count($this->_var['locations'])>1){ ?>
									 <div class="blank"></div>
									 <select name="locations" id="locations_select">
									 	{foreach from=$locations item=location}
									 	<option value="{$location.id}">{$location.name}</option>
										{/foreach}
									 </select>
									 <div class="blank"></div>
									 <?PHP }?>
									<ul>	
										<span id="sp_location">
										{if $deal.supplier_address_info.xpoint && $deal.supplier_address_info.ypoint}																	
										<li>
										<span class="saler_map">
											<img src="http://ditu.google.cn/maps/api/staticmap?zoom=13&size=194x194&maptype=roadmap&mobile=true&markers={$deal.supplier_address_info.ypoint},{$deal.supplier_address_info.xpoint}&sensor=false&language=zh_CN" />
											<a href='http://ditu.google.cn/maps?f=q&source=s_q&hl=zh-CN&geocode=&q={function name="urlencode" value=$deal.supplier_address_info.api_address}' target="_blank">{$LANG.VIEW_MAP}</a>										
										</span>
										</li>	
										{/if}					
										{if $deal.supplier_address_info.address}				
										<li>{$deal.supplier_address_info.address}</li>		
										{/if}		
										{if $deal.supplier_address_info.tel}						
										<li>{$deal.supplier_address_info.tel}‎</li>	
										{/if}	
										{if $deal.supplier_address_info.open_time}									
										<li>{$LANG.OPEN_TIME}：{$deal.supplier_address_info.open_time}‎</li>	
										{/if}	
										{if $deal.supplier_address_info.route}										
										<li>{$LANG.BUS_ROUTE}：{$deal.supplier_address_info.route}‎</li>											
										{/if}	
										</span>	
									</ul>
									<div class="blank"></div>
									{if $deal.supplier_info.preview}			
										<span style="text-align:center">										
										<img src="{$deal.supplier_info.preview} " width="200">
										</span>		
									{/if}
								</div>
							</div>
							<div class=clear></div>

						</div>
						<div class=box-bottom></div>
					</div>
				</div>
			</div>
			<div style="padding-top: 30px;">
			{include file="inc/side.html"} 
			</div>
	</div>
	<!-- bd end -->
</div>
{if ($deal.begin_time ne 0 and $deal.time_status eq 0) or ($deal.end_time ne 0 and $deal.time_status eq 1)} {* 时间 *}
<script type="text/javascript">
{if $deal.time_status eq 1} {*/结束倒计时/*}
var endTime = {$deal.end_time}000;
var nowTime = {function name=get_gmtime}000;
var sysSecond = (endTime - nowTime) / 1000;
{/if}
{if $deal.time_status eq 0} {*/开始倒计时/*}
var beginTime = {$deal.begin_time}000;
var nowTime = {function name=get_gmtime}000;
var sysSecond = (beginTime - nowTime) / 1000;
{/if}
var interValObj;
setRemainTime();
function setRemainTime()
{	
	if (sysSecond > 0)
	{
		var second = Math.floor(sysSecond % 60);              // 计算秒     
		var minite = Math.floor((sysSecond / 60) % 60);       //计算分
		var hour = Math.floor((sysSecond / 3600) % 24);       //计算小时
		var day = Math.floor((sysSecond / 3600) / 24);        //计算天
		var timeHtml = "<span>"+hour+"</span>"+LANG['HOUR']+"<span>"+minite+"</span>"+LANG['MIN']+"";
		if(day > 0)
			timeHtml ="<span>"+day+"</span>"+LANG['DAY']+"" + timeHtml;
		
		timeHtml+="<span>"+second+"</span>"+LANG['SEC']+"";
		
		try
		{
			$("#counter").html(timeHtml);
			sysSecond--;
		}
		catch(e){}}
	else
	{window.clearTimeout(interValObj);}
	interValObj = window.setTimeout("setRemainTime()", 1000); 	
}
</script>
{/if}
<!--图片轮播-->
<script type="text/javascript">

var errHideTimeOut;
var userMenuTimeOut;
var ecvTimeOut;
var imgListCurr=0;
var imgListNext=0;
var imgListCount=0;
var imgListInterval;

function imagesInit()
{
	imgListCount = $('#img_list a').size();
	
	if(imgListCount < 2)
		return;
	
	imgListInterval = setInterval('imagesRun()',3000);
	 
	$('#goods_imgs li,#img_list a').hover(function(){
		clearInterval(imgListInterval);
	},function(){
		imgListInterval = setInterval('imagesRun()',3000);
	});
	 
	$('#img_list a').click(function(){
		var index = $('#img_list a').index(this);
		if (imgListCurr != index){
			imagesPlay(index);
            imgListCurr = index;
        };
		return false;
    });
}

function imagesRun()
{
	imgListNext = imgListCurr + 1;
    if (imgListCurr == imgListCount - 1)
		imgListNext = 0;
		
	imagesPlay(imgListNext);
	
	imgListCurr++;
	
    if (imgListCurr > imgListCount - 1)
	{
		imgListCurr = 0;
		imgListNext = imgListCurr + 1;
	}
}

function imagesPlay(next)
{
	$('#goods_imgs li').eq(imgListCurr).css({'opacity':'0.5'}).animate({'left':'-440px','opacity':'1'},'slow',function(){
		$(this).css({'left':'440px' });
	}).end().eq(next).animate({'left':'0px','opacity':'1'},'slow',function(){
		$('#img_list a').siblings('a').removeClass('active').end().eq(next).addClass('active');
	});
}
function switch_location()
{
	var location_id = $("#locations_select").val();
	$.ajax({
		url: APP_ROOT+"/ajax.php?act=get_supplier_location&id="+location_id,
		success:function(html)
		{
			$("#sp_location").html(html);
		}
	});
}
$(document).ready(function(){
	imagesInit();
	$("#locations_select").bind("change",function(){
		switch_location();
	});
});
</script>
{include file="inc/footer.html"}